package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验：
 * 
 * 教训：
 * 
 * 分类：
 * 计算几何
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2653 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2653.class.getResource("P2653.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine().trim();
		while (line != null && !"0".equals(line)) {
			int n = Integer.valueOf(line);
			Segment[] segments = new Segment[n];
			for (int i = 0; i < n; i ++) {
				line = stdin.readLine().trim();
				segments[i] = Segment.getInstance(line, i+1);
				for (int j = 0; j < i; j ++) {
					if (segments[j] != null && segments[i].intersect(segments[j])) {
						segments[j] = null;
					}
				}
			}

			StringBuffer sb = new StringBuffer("Top sticks:");
			int index = 0;
			for (int i = 0; i < n; i ++) {
				if (segments[i] != null) { 
					if (index == 0) {
						sb.append(" " + segments[i].index);
					} else {
						sb.append(", " + segments[i].index);
					}
					index ++;
				}
			}
			sb.append(".");
			System.out.println(sb);
			
			line = stdin.readLine().trim();
		}
	}
	
	private static class Point {
		double x;
		double y;
	}
	
	private static class Segment {
		
		int index;
		Point p1;
		Point p2;
		
		public static Segment getInstance(String str, int index) {
			
			Segment ns = new Segment();
			StringTokenizer st = new StringTokenizer(str);
			ns.p1 = new Point();
			ns.p1.x = Double.valueOf(st.nextToken());
			ns.p1.y = Double.valueOf(st.nextToken());
			ns.p2 = new Point();
			ns.p2.x = Double.valueOf(st.nextToken());
			ns.p2.y = Double.valueOf(st.nextToken());
			if (ns.p1.x > ns.p2.x) {
				double x = ns.p1.x;
				ns.p2.x = ns.p1.x;
				ns.p1.x = x;
				double y = ns.p1.y;
				ns.p2.y = ns.p1.y;
				ns.p1.y = y;
			} else if (ns.p1.x == ns.p2.x && ns.p1.y > ns.p2.y) {
				double y = ns.p1.y;
				ns.p2.y = ns.p1.y;
				ns.p1.y = y;
			}
			
			ns.index = index;
			return ns;
		}
		
		public boolean intersect(Segment segment) {
			
	        double px1 = this.p1.x, px2 = this.p2.x, px3 = segment.p1.x, px4 = segment.p2.x;
	        double py1 = this.p1.y, py2 = this.p2.y, py3 = segment.p1.y, py4 = segment.p2.y;
	        double d = (px2-px1)*(py4-py3) - (py2-py1)*(px4-px3);
	        if(d!=0) {
	            double r = ((py1-py3)*(px4-px3)-(px1-px3)*(py4-py3))/d;
	            double s = ((py1-py3)*(px2-px1)-(px1-px3)*(py2-py1))/d;
	            if((r>=0) && (r <= 1) && (s >=0) && (s<=1)) {
	                return true;
	            }
	        }
	        return false;
	    }

		
		public boolean overlaped(Segment segment) {
			
			double eps = 1.0e-8;
			double area1 = area2(this.p1, this.p2, segment.p1);
			double area2 = area2(this.p1, this.p2, segment.p2);
			if (area1*area2 > 0.0f) {
				return false;
			} else {
				double area3 = area2(segment.p1, segment.p2, this.p1);
				double area4 = area2(segment.p1, segment.p2, this.p2);
				if (area3*area4 > 0.0f) {
					return false;
				} else {
					if (Math.abs(area1) < eps && Math.abs(area2) < eps 
						&& Math.abs(area3) < eps && Math.abs(area4) < eps) {//共线
							
							return (this.p2.x >= segment.p1.x && this.p2.x <= segment.p2.x)
								|| (segment.p2.x >= this.p1.x && segment.p2.x <= this.p2.x)
								|| (this.p2.y >= segment.p1.y && this.p2.y <= segment.p2.y)
								|| (segment.p2.y >= this.p1.y && segment.p2.y <= this.p2.y);
					} else {
						return true;
					}
				}
			}
		}
		
		private static double area2(Point p1, Point p2, Point p3) {
			return (p3.x-p2.x)*(p1.y-p2.y) + (p2.x-p1.x)*(p3.y-p2.y);
		}
	}
}
